package c.e.a.b.a.a;

import android.net.Uri;
import android.net.Uri.Builder;
import android.util.Log;
import com.huawei.agconnect.exception.AGCServerException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;

public final class b extends Thread {
    public final /* synthetic */ Map a;

    public b(Map map) {
        this.a = map;
    }

    public final void run() {
        Throwable e;
        String message;
        StringBuilder stringBuilder;
        String str;
        String str2 = ". ";
        String str3 = "HttpUrlPinger";
        Map map = this.a;
        Builder buildUpon = Uri.parse("https://pagead2.googlesyndication.com/pagead/gen_204?id=gmob-apps").buildUpon();
        for (String str4 : map.keySet()) {
            buildUpon.appendQueryParameter(str4, (String) map.get(str4));
        }
        String uri = buildUpon.build().toString();
        HttpURLConnection httpURLConnection;
        try {
            httpURLConnection = (HttpURLConnection) new URL(uri).openConnection();
            int responseCode = httpURLConnection.getResponseCode();
            if (responseCode < AGCServerException.OK || responseCode >= 300) {
                StringBuilder stringBuilder2 = new StringBuilder(String.valueOf(uri).length() + 65);
                stringBuilder2.append("Received non-success response code ");
                stringBuilder2.append(responseCode);
                stringBuilder2.append(" from pinging URL: ");
                stringBuilder2.append(uri);
                Log.w(str3, stringBuilder2.toString());
            }
            httpURLConnection.disconnect();
        } catch (IndexOutOfBoundsException e2) {
            e = e2;
            message = e.getMessage();
            stringBuilder = new StringBuilder(String.valueOf(message).length() + (String.valueOf(uri).length() + 32));
            str = "Error while parsing ping URL: ";
            stringBuilder.append(str);
            stringBuilder.append(uri);
            stringBuilder.append(str2);
            stringBuilder.append(message);
            Log.w(str3, stringBuilder.toString(), e);
        } catch (IOException | RuntimeException e3) {
            e = e3;
            message = e.getMessage();
            stringBuilder = new StringBuilder(String.valueOf(message).length() + (String.valueOf(uri).length() + 27));
            str = "Error while pinging URL: ";
            stringBuilder.append(str);
            stringBuilder.append(uri);
            stringBuilder.append(str2);
            stringBuilder.append(message);
            Log.w(str3, stringBuilder.toString(), e);
        } catch (Throwable th) {
            httpURLConnection.disconnect();
        }
    }
}
